
<?php


 /**
  * Customer Value Object.
  * This class is value object representing database table Customer
  * This class is intented to be used together with associated Dao object.
  */

class Customer {

    /** 
     * Persistent Instance variables. This data is directly 
     * mapped to the columns of database table.
     */
    var $CustomerID;
    var $LastName;
    var $FirstName;
    var $Address;
    var $City;
    var $State;
    var $Zip;
    var $PhoneNumber1;
    var $PhoneNumber2;
    var $PhoneNumber3;
    var $Email;



    /** 
     * Constructors.
     * The first one takes no arguments and provides the most simple
     * way to create object instance. The another one takes one
     * argument, which is the primary key of the corresponding table.
     */

    function Customer () {

    }

    /* function Customer ($CustomerIDIn) {

          $this->CustomerID = $CustomerIDIn;

    } */


    /** 
     * Get- and Set-methods for persistent variables. The default
     * behaviour does not make any checks against malformed data,
     * so these might require some manual additions.
     */

    function getCustomerID() {
          return $this->CustomerID;
    }
    function setCustomerID($CustomerIDIn) {
          $this->CustomerID = $CustomerIDIn;
    }

    function getLastName() {
          return $this->LastName;
    }
    function setLastName($LastNameIn) {
          $this->LastName = $LastNameIn;
    }

    function getFirstName() {
          return $this->FirstName;
    }
    function setFirstName($FirstNameIn) {
          $this->FirstName = $FirstNameIn;
    }

    function getAddress() {
          return $this->Address;
    }
    function setAddress($AddressIn) {
          $this->Address = $AddressIn;
    }

    function getCity() {
          return $this->City;
    }
    function setCity($CityIn) {
          $this->City = $CityIn;
    }

    function getState() {
          return $this->State;
    }
    function setState($StateIn) {
          $this->State = $StateIn;
    }

    function getZip() {
          return $this->Zip;
    }
    function setZip($ZipIn) {
          $this->Zip = $ZipIn;
    }

    function getPhoneNumber1() {
          return $this->PhoneNumber1;
    }
    function setPhoneNumber1($PhoneNumber1In) {
          $this->PhoneNumber1 = $PhoneNumber1In;
    }

    function getPhoneNumber2() {
          return $this->PhoneNumber2;
    }
    function setPhoneNumber2($PhoneNumber2In) {
          $this->PhoneNumber2 = $PhoneNumber2In;
    }

    function getPhoneNumber3() {
          return $this->PhoneNumber3;
    }
    function setPhoneNumber3($PhoneNumber3In) {
          $this->PhoneNumber3 = $PhoneNumber3In;
    }

    function getEmail() {
          return $this->Email;
    }
    function setEmail($EmailIn) {
          $this->Email = $EmailIn;
    }



    /** 
     * setAll allows to set all persistent variables in one method call.
     * This is useful, when all data is available and it is needed to 
     * set the initial state of this object. Note that this method will
     * directly modify instance variales, without going trough the 
     * individual set-methods.
     */

    function setAll($CustomerIDIn,
          $LastNameIn,
          $FirstNameIn,
          $AddressIn,
          $CityIn,
          $StateIn,
          $ZipIn,
          $PhoneNumber1In,
          $PhoneNumber2In,
          $PhoneNumber3In,
          $EmailIn) {
          $this->CustomerID = $CustomerIDIn;
          $this->LastName = $LastNameIn;
          $this->FirstName = $FirstNameIn;
          $this->Address = $AddressIn;
          $this->City = $CityIn;
          $this->State = $StateIn;
          $this->Zip = $ZipIn;
          $this->PhoneNumber1 = $PhoneNumber1In;
          $this->PhoneNumber2 = $PhoneNumber2In;
          $this->PhoneNumber3 = $PhoneNumber3In;
          $this->Email = $EmailIn;
    }


    /** 
     * hasEqualMapping-method will compare two Customer instances
     * and return true if they contain same values in all persistent instance 
     * variables. If hasEqualMapping returns true, it does not mean the objects
     * are the same instance. However it does mean that in that moment, they 
     * are mapped to the same row in database.
     */
    function hasEqualMapping($valueObject) {

          if ($valueObject->getCustomerID() != $this->CustomerID) {
                    return(false);
          }
          if ($valueObject->getLastName() != $this->LastName) {
                    return(false);
          }
          if ($valueObject->getFirstName() != $this->FirstName) {
                    return(false);
          }
          if ($valueObject->getAddress() != $this->Address) {
                    return(false);
          }
          if ($valueObject->getCity() != $this->City) {
                    return(false);
          }
          if ($valueObject->getState() != $this->State) {
                    return(false);
          }
          if ($valueObject->getZip() != $this->Zip) {
                    return(false);
          }
          if ($valueObject->getPhoneNumber1() != $this->PhoneNumber1) {
                    return(false);
          }
          if ($valueObject->getPhoneNumber2() != $this->PhoneNumber2) {
                    return(false);
          }
          if ($valueObject->getPhoneNumber3() != $this->PhoneNumber3) {
                    return(false);
          }
          if ($valueObject->getEmail() != $this->Email) {
                    return(false);
          }

          return true;
    }



    /**
     * toString will return String object representing the state of this 
     * valueObject. This is useful during application development, and 
     * possibly when application is writing object states in textlog.
     */
    function toString() {

        $out = $out."\nclass Customer, mapping to table Customer\n";
        $out = $out."Persistent attributes: \n"; 
        $out = $out."CustomerID = ".$this->CustomerID."\n"; 
        $out = $out."LastName = ".$this->LastName."\n"; 
        $out = $out."FirstName = ".$this->FirstName."\n"; 
        $out = $out."Address = ".$this->Address."\n"; 
        $out = $out."City = ".$this->City."\n"; 
        $out = $out."State = ".$this->State."\n"; 
        $out = $out."Zip = ".$this->Zip."\n"; 
        $out = $out."PhoneNumber1 = ".$this->PhoneNumber1."\n"; 
        $out = $out."PhoneNumber2 = ".$this->PhoneNumber2."\n"; 
        $out = $out."PhoneNumber3 = ".$this->PhoneNumber3."\n"; 
        $out = $out."Email = ".$this->Email."\n"; 
        return $out;
    }


    /**
     * Clone will return identical deep copy of this valueObject.
     * Here, the retuned cloned object will also have all its attributes cloned.
     */
    function clone1() {
        $cloned = new Customer();

        $cloned->setCustomerID($this->CustomerID); 
        $cloned->setLastName($this->LastName); 
        $cloned->setFirstName($this->FirstName); 
        $cloned->setAddress($this->Address); 
        $cloned->setCity($this->City); 
        $cloned->setState($this->State); 
        $cloned->setZip($this->Zip); 
        $cloned->setPhoneNumber1($this->PhoneNumber1); 
        $cloned->setPhoneNumber2($this->PhoneNumber2); 
        $cloned->setPhoneNumber3($this->PhoneNumber3); 
        $cloned->setEmail($this->Email); 

        return $cloned;
    }


}

?>
